/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jena.tests;

import java.util.Iterator;
import com.hp.hpl.jena.ontology.*;
import com.hp.hpl.jena.rdf.model.*;

/**
 *
 * @author Francisco
 */
public class JenaTest {

    public JenaTest()  {
        
    }
    
    public void test1()  {
        OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, null );

        // we have a local copy of the wine ontology
        m.getDocumentManager().addAltEntry( "http://www.w3.org/2001/sw/WebOnt/guide-src/wine",
                                            "file:/paco/testing/reasoners/bugs/wine.owl" );
        m.getDocumentManager().addAltEntry( "http://www.w3.org/2001/sw/WebOnt/guide-src/food",
                                            "file:/paco/testing/reasoners/bugs/food.owl" );

        m.read( "http://www.w3.org/2001/sw/WebOnt/guide-src/wine" );

        new ClassHierarchy().showHierarchy( System.out, m );
        
    }
    
    public void testDescribeClass(String cname)  {
       // read the argument file, or the default
        String source = "http://www.w3.org/TR/2003/CR-owl-guide-20030818/wine";

        // guess if we're using a daml source
        boolean isDAML = source.endsWith( ".daml" );

        OntModel m = ModelFactory.createOntologyModel(
                        isDAML ? OntModelSpec.DAML_MEM : OntModelSpec.OWL_MEM, null
                     );

        // we have a local copy of the wine ontology
        m.getDocumentManager().addAltEntry( "http://www.w3.org/TR/2003/CR-owl-guide-20030818/wine",
                                            "file:/paco/testing/reasoners/bugs/wine.owl" );
        m.getDocumentManager().addAltEntry( "http://www.w3.org/TR/2003/CR-owl-guide-20030818/food",
                                            "file:/paco/testing/reasoners/bugs/food.owl" );

        // read the source document
        m.read( source );

        DescribeClass dc = new DescribeClass();

        if ( cname != null ) {
            // we have a named class to describe
            OntClass c = m.getOntClass( cname );
            dc.describeClass( System.out, c );
        }
        else {
            for (Iterator i = m.listClasses();  i.hasNext(); ) {
                // now list the classes
                dc.describeClass( System.out, (OntClass) i.next() );
            }
        }        
    }
    
}
